SRCS := $(wildcard *.c)
OUTS := $(patsubst %.c,%,$(SRCS))
OFILE := $(patsubst %.c,%.o,$(SRCS))
CC := gcc
COM_OP := -Wall -g -lpthread
RESULT := main

$(RESULT): $(OFILE)
	gcc $(OFILE) -o $(RESULT) $(COM_OP) 
	$(RM) $(OFILE) 
$(OFILE): $(SRCS)
%.o : %.c
	$(CC) -c $< -o $@ $(COM_OP)


#这是执行每个c单独变成可执行文件
#all: $(OUTS)                      
#% : %.c
#	$(CC) $^ -o $@ $(COM_OP)

.PHONY: clean rebuild
clean:
	$(RM) $(OUTS) $(OFILE) $(RESULT)
rebuild: clean all
